package ua.com.fesvlast.hotel.model.commands;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ua.com.fesvlast.hotel.controller.managers.ConfigurationManager;
import ua.com.fesvlast.hotel.model.dao.DAOFactory;
import ua.com.fesvlast.hotel.model.enteties.Contacts;
import ua.com.fesvlast.hotel.model.enteties.Users;

public class ForwardContact implements ICommand {

	@Override
	public String execute(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		String page=null;	
		
		Users user =(Users)request.getSession().getAttribute("currentUser");
		page=ConfigurationManager.getInstance().getProperty(ConfigurationManager.CONTACT_PAGE);
		Contacts contact=new Contacts();
		
		if(user!=null){
			contact =DAOFactory.getContactsDAO().getCurrentContactByID(user.getUserId());
			request.setAttribute("currentContact", contact);
		}
		

		return page;
	}

}
